package com.stu.manager.studentscoremanagersys.controller;

import com.stu.manager.studentscoremanagersys.req.LoginReq;
import com.stu.manager.studentscoremanagersys.res.Result;
import com.stu.manager.studentscoremanagersys.service.ManagerService;
import com.stu.manager.studentscoremanagersys.vo.JWTManagerVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
@Slf4j
public class ManagerHandler {

    @Autowired
    ManagerService managerService;

    // content-Type:application/json
    @PostMapping("/login")
    public Result<JWTManagerVo> login(@RequestBody @Validated LoginReq loginReq){
        log.info("login params:{}",loginReq);
        return managerService.login(loginReq);
    }

    // content-Type:application/x-www-form-urlencoded
    @PostMapping("/login2")
    public Result<JWTManagerVo> login2(@Validated LoginReq loginReq){
        log.info("login2 params:{}",loginReq);
        return managerService.login(loginReq);
    }
}
